#pragma once
#include <memory>
#include <mutex>
#include "OutputSource.h"
#include "SqlTableOp.h"
namespace Media{

    class OutputSourceManager{
    public:
        using Ptr = std::shared_ptr<OutputSourceManager>;
        static Ptr Instance();
        OutputSourceManager();
        ~OutputSourceManager();

        bool AddSource(const outputSourceTable& config, uint32_t& id);
        bool RemoveSource(uint32_t id);
        bool GetOneSourceConfig(uint32_t id, outputSourceTable& config);
        bool GetAllSourceConfig(std::vector<outputSourceTable>& configs);
        
        OutputSource::Ptr GetSource(uint32_t id);
    private:
        void init();
        void outInterfaceCheck();

        static OutputSource::Ptr createOutputSource(const SourceConfig& config);

        std::map<OutputSource::OutputSourceId, OutputSource::Ptr> m_sources;
        std::recursive_mutex m_mux;
        SqlTableOp::Ptr m_sql;

    };
}